<!DOCTYPE html>
<html lang="en">
  <head>
    <title>ConnectionPool Class Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
	<meta name="viewport" content="width=device-width, viewport-fit=cover, initial-scale=1.0" />
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Class/ConnectionPool" class="dashAnchor"></a>
    <a title="ConnectionPool Class Reference"></a>
    <header>
      <div class="content-wrapper">
        <p>
          <a href="../index.html">PostgresClientKit Docs</a>
          <span class="no-mobile"> (100% documented)</span>
        </p>
    
        <p class="header-right">
          <a href="https://github.com/codewinsdotcom/PostgresClientKit">
            <img src="../img/gh.png"/>
            <span class="no-mobile">View on GitHub</span>
          </a>
        </p>
    
      </div>
    </header>
    <div id="breadcrumbs-container">
      <div class="content-wrapper">
        <p id="breadcrumbs">
          <span class="no-mobile">
            <a href="../index.html">PostgresClientKit Reference</a>
            <img id="carat" src="../img/carat.png" />
          </span>
          ConnectionPool Class Reference
        </p>
      </div>
    </div>
    <div class="wrapper">
      <div class="article-wrapper">
        <article class="main-content">
          <section>
            <section class="section">
              <h1>ConnectionPool</h1>
                <div class="declaration">
                  <div class="language">
                    <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">ConnectionPool</span></code></pre>

                  </div>
                </div>
              <p>A pool of re-usable, interchangeable <code><a href="../Classes/Connection.html">Connection</a></code> instances.</p>

<p>Using a <code>ConnectionPool</code> allows an application to acquire an existing <code><a href="../Classes/Connection.html">Connection</a></code> from the
pool, use that connection to perform one or more SQL statements, and then release it for use
elsewhere in the application.</p>

<p>The <code><a href="../Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a></code> used to create a <code>ConnectionPool</code> specifies the number of
connections in the pool, how long a request for a connection will wait for a connection to
become available, and other characteristics of the pool.</p>

<p>All connections in a <code>ConnectionPool</code> are created from the same <code><a href="../Structs/ConnectionConfiguration.html">ConnectionConfiguration</a></code>.
They also have the same <code><a href="../Protocols/ConnectionDelegate.html">ConnectionDelegate</a></code> (if a delegate is specified).  Consequently
any connection in a pool is interchangeable with any other.</p>

<p>Use <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">ConnectionPool.acquireConnection(completionHandler:)</a></code> to request a connection from a
<code>ConnectionPool</code>.  This method is non-blocking: its completion handler is asynchronously
executed when a connection is successfully allocated to the request or if an error occurs.
To release the connection back to the pool, call <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">ConnectionPool.releaseConnection(_:)</a></code>.</p>

<p>Alternately, use <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC04withD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">ConnectionPool.withConnection(completionHandler:)</a></code> to acquire a connection
that is automatically released after execution of the completion handler.</p>

<p>When a connection is released to a <code>ConnectionPool</code>, there should be no transaction underway.
Pair each SQL <code>BEGIN</code> command with either a <code>COMMIT</code> or <code>ROLLBACK</code> command (or equivalently,
use the <code><a href="../Classes/Connection.html#/s:17PostgresClientKit10ConnectionC16beginTransactionyyKF">Connection.beginTransaction()</a></code>, <code><a href="../Classes/Connection.html#/s:17PostgresClientKit10ConnectionC17commitTransactionyyKF">Connection.commitTransaction()</a></code>, and
<code><a href="../Classes/Connection.html#/s:17PostgresClientKit10ConnectionC19rollbackTransactionyyKF">Connection.rollbackTransaction()</a></code> methods).</p>

<p>In general, do not close a <code><a href="../Classes/Connection.html">Connection</a></code> acquired from a <code>ConnectionPool</code>.  If a connection is
closed (whether explicitly or because of an unrecoverable error) then, when that connection is
released, it will be discarded from the pool, allowing a new connection to be created and added
to the pool.</p>

<p>The <code>ConnectionPool</code> class is threadsafe: multiple threads may concurrently operate against a
<code>ConnectionPool</code> instance.  Connections acquired from the pool are subject to the threadsafety
constraints described by the API documentation for <code><a href="../Classes/Connection.html">Connection</a></code>.</p>

            </section>
            <section class="section task-group-section">
              <div class="task-group">
                <ul>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC010connectionE13Configuration0fG00F8DelegateAcA0deG0V_AA0dG0VAA0dH0_pSgtcfc"></a>
                      <a name="//apple_ref/swift/Method/init(connectionPoolConfiguration:connectionConfiguration:connectionDelegate:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC010connectionE13Configuration0fG00F8DelegateAcA0deG0V_AA0dG0VAA0dH0_pSgtcfc">init(connectionPoolConfiguration:connectionConfiguration:connectionDelegate:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Creates a <code>ConnectionPool</code>.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">connectionPoolConfiguration</span><span class="p">:</span> <span class="kt"><a href="../Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a></span><span class="p">,</span>
            <span class="nv">connectionConfiguration</span><span class="p">:</span> <span class="kt"><a href="../Structs/ConnectionConfiguration.html">ConnectionConfiguration</a></span><span class="p">,</span>
            <span class="nv">connectionDelegate</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ConnectionDelegate.html">ConnectionDelegate</a></span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>connectionPoolConfiguration</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>the configuration for the <code>ConnectionPool</code></p>
                                  </div>
                                </td>
                              </tr>
                              <tr>
                                <td>
                                  <code>
                                  <em>connectionConfiguration</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>the configuration for <code><a href="../Classes/Connection.html">Connection</a></code> instances in the pool</p>
                                  </div>
                                </td>
                              </tr>
                              <tr>
                                <td>
                                  <code>
                                  <em>connectionDelegate</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>an optional delegate for the <code><a href="../Classes/Connection.html">Connection</a></code> instances</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC010connectionE13ConfigurationAA0deG0Vvp"></a>
                      <a name="//apple_ref/swift/Property/connectionPoolConfiguration" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC010connectionE13ConfigurationAA0deG0Vvp">connectionPoolConfiguration</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>The configuration of this <code>ConnectionPool</code>.</p>

<p>The <code><a href="../Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a></code> is mutable.  Configuration changes take effect for
subsequent requests for connections.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">connectionPoolConfiguration</span><span class="p">:</span> <span class="kt"><a href="../Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a></span> <span class="p">{</span> <span class="k">get</span> <span class="k">set</span> <span class="p">}</span></code></pre>

                          </div>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC23connectionConfigurationAA0dG0Vvp"></a>
                      <a name="//apple_ref/swift/Property/connectionConfiguration" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC23connectionConfigurationAA0dG0Vvp">connectionConfiguration</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>The configuration of <code><a href="../Classes/Connection.html">Connection</a></code> instances in this <code>ConnectionPool</code>.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">let</span> <span class="nv">connectionConfiguration</span><span class="p">:</span> <span class="kt"><a href="../Structs/ConnectionConfiguration.html">ConnectionConfiguration</a></span></code></pre>

                          </div>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC18connectionDelegateAA0dG0_pSgvp"></a>
                      <a name="//apple_ref/swift/Property/connectionDelegate" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC18connectionDelegateAA0dG0_pSgvp">connectionDelegate</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>An optional delegate for <code><a href="../Classes/Connection.html">Connection</a></code> instances in this <code>ConnectionPool</code>.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">let</span> <span class="nv">connectionDelegate</span><span class="p">:</span> <span class="kt"><a href="../Protocols/ConnectionDelegate.html">ConnectionDelegate</a></span><span class="p">?</span></code></pre>

                          </div>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF"></a>
                      <a name="//apple_ref/swift/Method/acquireConnection(completionHandler:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">acquireConnection(completionHandler:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Requests a <code><a href="../Classes/Connection.html">Connection</a></code> from this <code>ConnectionPool</code>.</p>

<p>This method is non-blocking: its completion handler is asynchronously executed when a
connection is successfully allocated or an error occurs.
<code><a href="../Structs/ConnectionPoolConfiguration.html#/s:17PostgresClientKit27ConnectionPoolConfigurationV13dispatchQueueSo03OS_G6_queueCvp">ConnectionPoolConfiguration.dispatchQueue</a></code> controls the <code>DispatchQueue</code> on which the
completion handler is executed.</p>

<p>If the request backlog is too large (<code><a href="../Structs/ConnectionPoolConfiguration.html#/s:17PostgresClientKit27ConnectionPoolConfigurationV22maximumPendingRequestsSiSgvp">ConnectionPoolConfiguration.maximumPendingRequests</a></code>),
the request will fail with <code><a href="../Enums/PostgresError.html#/s:17PostgresClientKit0A5ErrorO29tooManyRequestsForConnectionsyA2CmF">PostgresError.tooManyRequestsForConnections</a></code>.</p>

<p>If a connection is available, it will be allocated to the request and passed to the
completion handler.  Otherwise, the request will join the backlog of pending requests.
As connections become available, they are allocated to the pending requests in the order
those requests were received.</p>

<p>If a connection is not allocated to the request before it times out
(<code><a href="../Structs/ConnectionPoolConfiguration.html#/s:17PostgresClientKit27ConnectionPoolConfigurationV21pendingRequestTimeoutSiSgvp">ConnectionPoolConfiguration.pendingRequestTimeout</a></code>), the request will fail with
<code><a href="../Enums/PostgresError.html#/s:17PostgresClientKit0A5ErrorO27timedOutAcquiringConnectionyA2CmF">PostgresError.timedOutAcquiringConnection</a></code>.</p>

<p>When a connection is successfully allocated to the request, the completion handler
(or any code it triggers) can use that connection to perform one or more SQL statements.
When finished with the connection, call <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">releaseConnection(_:)</a></code> to release it back to
this <code>ConnectionPool</code>.  If <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">releaseConnection(_:)</a></code> is not called before the allocated
connection times out (<code><a href="../Structs/ConnectionPoolConfiguration.html#/s:17PostgresClientKit27ConnectionPoolConfigurationV09allocatedD7TimeoutSiSgvp">ConnectionPoolConfiguration.allocatedConnectionTimeout</a></code>), the
connection will be forcibly closed and removed from the <code>ConnectionPool</code>.</p>

<p>Example:</p>
<pre class="highlight swift"><code><span class="n">connectionPool</span><span class="o">.</span><span class="n">acquireConnection</span> <span class="p">{</span> <span class="n">result</span> <span class="k">in</span>
    <span class="k">do</span> <span class="p">{</span>
        <span class="k">let</span> <span class="nv">connection</span> <span class="o">=</span> <span class="k">try</span> <span class="n">result</span><span class="o">.</span><span class="nf">get</span><span class="p">()</span>
        <span class="k">defer</span> <span class="p">{</span> <span class="n">connectionPool</span><span class="o">.</span><span class="nf">releaseConnection</span><span class="p">(</span><span class="n">connection</span><span class="p">)</span> <span class="p">}</span>

        <span class="k">let</span> <span class="nv">statement</span> <span class="o">=</span> <span class="k">try</span> <span class="n">connection</span><span class="o">.</span><span class="nf">prepareStatement</span><span class="p">(</span><span class="nv">text</span><span class="p">:</span> <span class="o">...</span><span class="p">)</span>
        <span class="o">...</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">{</span>
        <span class="o">...</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">acquireConnection</span><span class="p">(</span>
    <span class="nv">completionHandler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">Result</span><span class="o">&lt;</span><span class="kt"><a href="../Classes/Connection.html">Connection</a></span><span class="p">,</span> <span class="kt">Error</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>completionHandler</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>a completion handler, passed a value that either indicates
success (with an associated <code><a href="../Classes/Connection.html">Connection</a></code>) or failure (with an associated <code>Error</code>)</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF"></a>
                      <a name="//apple_ref/swift/Method/releaseConnection(_:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">releaseConnection(_:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Releases a <code><a href="../Classes/Connection.html">Connection</a></code> back to this <code>ConnectionPool</code>.</p>

<p>Each <code><a href="../Classes/Connection.html">Connection</a></code> acquired by calling <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">acquireConnection(completionHandler:)</a></code> should be
released exactly once.  After invoking this method, do not further operate on the
<code><a href="../Classes/Connection.html">Connection</a></code> instance.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">releaseConnection</span><span class="p">(</span><span class="n">_</span> <span class="nv">connection</span><span class="p">:</span> <span class="kt"><a href="../Classes/Connection.html">Connection</a></span><span class="p">)</span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>connection</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>the <code><a href="../Classes/Connection.html">Connection</a></code> to release</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC04withD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF"></a>
                      <a name="//apple_ref/swift/Method/withConnection(completionHandler:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC04withD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">withConnection(completionHandler:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Requests a <code><a href="../Classes/Connection.html">Connection</a></code> from this <code>ConnectionPool</code>, automatically releasing it after
executing the specified completion handler.</p>

<p>This method operates identically to <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07acquireD017completionHandleryys6ResultOyAA0D0Cs5Error_pGc_tF">acquireConnection(completionHandler:)</a></code>, except that
the acquired connection is automatically released after executing the completion handler.</p>

<p>Do not call <code><a href="../Classes/ConnectionPool.html#/s:17PostgresClientKit14ConnectionPoolC07releaseD0yyAA0D0CF">releaseConnection(_:)</a></code> on the <code><a href="../Classes/Connection.html">Connection</a></code> passed to the completion handler.</p>

<p>Example:</p>
<pre class="highlight swift"><code><span class="n">connectionPool</span><span class="o">.</span><span class="n">withConnection</span> <span class="p">{</span> <span class="n">result</span> <span class="k">in</span>
    <span class="k">do</span> <span class="p">{</span>
        <span class="k">let</span> <span class="nv">connection</span> <span class="o">=</span> <span class="k">try</span> <span class="n">result</span><span class="o">.</span><span class="nf">get</span><span class="p">()</span>
        <span class="k">let</span> <span class="nv">statement</span> <span class="o">=</span> <span class="k">try</span> <span class="n">connection</span><span class="o">.</span><span class="nf">prepareStatement</span><span class="p">(</span><span class="nv">text</span><span class="p">:</span> <span class="o">...</span><span class="p">)</span>
        <span class="o">...</span>
    <span class="p">}</span> <span class="k">catch</span> <span class="p">{</span>
        <span class="o">...</span>
    <span class="p">}</span>
<span class="p">}</span>
</code></pre>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">withConnection</span><span class="p">(</span><span class="nv">completionHandler</span><span class="p">:</span> <span class="kd">@escaping</span> <span class="p">(</span><span class="kt">Result</span><span class="o">&lt;</span><span class="kt"><a href="../Classes/Connection.html">Connection</a></span><span class="p">,</span> <span class="kt">Error</span><span class="o">&gt;</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt">Void</span><span class="p">)</span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>completionHandler</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>a completion handler, passed a value that either indicates
success (with an associated <code><a href="../Classes/Connection.html">Connection</a></code>) or failure (with an associated <code>Error</code>)</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC14computeMetrics5resetAA0deG0VSb_tF"></a>
                      <a name="//apple_ref/swift/Method/computeMetrics(reset:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC14computeMetrics5resetAA0deG0VSb_tF">computeMetrics(reset:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Gets performance metrics for this <code>ConnectionPool</code>.</p>

<p>The returned metrics describe <code>ConnectionPool</code> performance for the period starting when
the metrics were last reset (or when this <code>ConnectionPool</code> was initialized, if the metrics
have never been reset) and ending at the current moment in time.</p>

<p>Performance metrics can also be periodically logged. See
<code><a href="../Structs/ConnectionPoolConfiguration.html#/s:17PostgresClientKit27ConnectionPoolConfigurationV22metricsLoggingIntervalSiSgvp">ConnectionPoolConfiguration.metricsLoggingInterval</a></code>.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">@discardableResult</span>
<span class="kd">public</span> <span class="kd">func</span> <span class="nf">computeMetrics</span><span class="p">(</span><span class="nv">reset</span><span class="p">:</span> <span class="kt">Bool</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="kt"><a href="../Structs/ConnectionPoolMetrics.html">ConnectionPoolMetrics</a></span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>reset</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>whether to reset the metrics</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                        <div>
                          <h4>Return Value</h4>
                          <p>the metrics</p>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC8isClosedSbvp"></a>
                      <a name="//apple_ref/swift/Property/isClosed" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC8isClosedSbvp">isClosed</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Whether this <code>ConnectionPool</code> is closed.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="k">var</span> <span class="nv">isClosed</span><span class="p">:</span> <span class="kt">Bool</span> <span class="p">{</span> <span class="k">get</span> <span class="p">}</span></code></pre>

                          </div>
                        </div>
                      </section>
                    </div>
                  </li>
                  <li class="item">
                    <div>
                      <code>
                      <a name="/s:17PostgresClientKit14ConnectionPoolC5close5forceySb_tF"></a>
                      <a name="//apple_ref/swift/Method/close(force:)" class="dashAnchor"></a>
                      <a class="token" href="#/s:17PostgresClientKit14ConnectionPoolC5close5forceySb_tF">close(force:)</a>
                      </code>
                    </div>
                    <div class="height-container">
                      <div class="pointer-container"></div>
                      <section class="section">
                        <div class="pointer"></div>
                        <div class="abstract">
                          <p>Closes this <code>ConnectionPool</code>.</p>

<p>Any pending requests for connections are canceled.</p>

<p>If <code>force</code> is <code>true</code>, all <code><a href="../Classes/Connection.html">Connection</a></code> instances in this <code>ConnectionPool</code> are immediately
forcibly closed.</p>

<p>If <code>force</code> is false, only the unallocated <code><a href="../Classes/Connection.html">Connection</a></code> instances are immediately closed.
The connections currently allocated to requests will be closed as those requests complete
and the connections are released.</p>

<p>Has no effect if this <code>ConnectionPool</code> is already closed.</p>

                        </div>
                        <div class="declaration">
                          <h4>Declaration</h4>
                          <div class="language">
                            <p class="aside-title">Swift</p>
                            <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">close</span><span class="p">(</span><span class="nv">force</span><span class="p">:</span> <span class="kt">Bool</span> <span class="o">=</span> <span class="kc">false</span><span class="p">)</span></code></pre>

                          </div>
                        </div>
                        <div>
                          <h4>Parameters</h4>
                          <table class="graybox">
                            <tbody>
                              <tr>
                                <td>
                                  <code>
                                  <em>force</em>
                                  </code>
                                </td>
                                <td>
                                  <div>
                                    <p>whether to immediately forcibly close <code><a href="../Classes/Connection.html">Connection</a></code> instances currently
allocated to requests</p>
                                  </div>
                                </td>
                              </tr>
                            </tbody>
                          </table>
                        </div>
                      </section>
                    </div>
                  </li>
                </ul>
              </div>
            </section>
          </section>
        </article>
      </div>
      <div class="nav-wrapper">
        <nav class="nav-bottom">
          <ul class="nav-groups">
            <li class="nav-group-name">
              <a href="../Classes.html">Classes</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Classes/Connection.html">Connection</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/ConnectionPool.html">ConnectionPool</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/ConsoleLogHandler.html">ConsoleLogHandler</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/Cursor.html">Cursor</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/Logger.html">Logger</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Classes/Statement.html">Statement</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Enums.html">Enumerations</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Enums/Credential.html">Credential</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/LogLevel.html">LogLevel</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Enums/PostgresError.html">PostgresError</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Extensions.html">Extensions</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Extensions/Bool.html">Bool</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/Date.html">Date</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/Decimal.html">Decimal</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/Double.html">Double</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/Int.html">Int</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/Optional.html">Optional</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Extensions/String.html">String</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Protocols.html">Protocols</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Protocols/ConnectionDelegate.html">ConnectionDelegate</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/LogHandler.html">LogHandler</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Protocols/PostgresValueConvertible.html">PostgresValueConvertible</a>
                </li>
              </ul>
            </li>
            <li class="nav-group-name">
              <a href="../Structs.html">Structures</a>
              <ul class="nav-group-tasks">
                <li class="nav-group-task">
                  <a href="../Structs/ColumnMetadata.html">ColumnMetadata</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/ConnectionConfiguration.html">ConnectionConfiguration</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/ConnectionPoolConfiguration.html">ConnectionPoolConfiguration</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/ConnectionPoolMetrics.html">ConnectionPoolMetrics</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/LogRecord.html">LogRecord</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/Notice.html">Notice</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/Postgres.html">Postgres</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresByteA.html">PostgresByteA</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresDate.html">PostgresDate</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresTime.html">PostgresTime</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresTimeWithTimeZone.html">PostgresTimeWithTimeZone</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresTimestamp.html">PostgresTimestamp</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresTimestampWithTimeZone.html">PostgresTimestampWithTimeZone</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/PostgresValue.html">PostgresValue</a>
                </li>
                <li class="nav-group-task">
                  <a href="../Structs/Row.html">Row</a>
                </li>
              </ul>
            </li>
          </ul>
        </nav>
      </div>
      <div class="footer-wrapper">
        <section id="footer">
          <p>Copyright 2019 David Pitfield and the PostgresClientKit contributors. Licensed under the Apache License, Version 2.0.</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </div>
    </div>
  </body>
</div>
</html>
